import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import "./plugins/video.js";
import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import '@/assets/styles/common.scss' // ruoyi css
import '@/assets/styles/custom.scss'
import '@/assets/styles/customForm.scss'
import '@/assets/styles/screenFull.scss'
import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'
import Print from 'vue-print-nb'
import './assets/icons' // icon
import './permission' // permission control
import { getDicts, getDictMultiLevels,getDictsAnon } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { parseTime, hideIdCardMiddle,resetForm, addDateRange, selectDictLabel, selectDictLabelMultiArray, handlePicturePath, handleFileList, download, handleTree, selectDeptName, selectDeptNameByTree,formatterType,getRatio } from "@/utils/ruoyi";
import { encryptEmail, encryptIdCard, encryptName, encryptPhone, getSpecifiedTime } from "@/utils/desensitization"
import { decrypt, encrypt } from '@/utils/jsencrypt';
import Pagination from "@/components/Pagination";
//点赞等使用的心型图标
import '@/assets/el-icon-third/iconfont.css';
// 字典数据组件
import DictData from '@/components/DictData'
import plugins from '@/plugins/index' // plugins
import DictTag from '@/components/DictTag'
// 将自动注册所有组件为全局组件
import dataV from '@jiaminghi/data-view'

Vue.use(dataV)
// h5+模块
var onPlusReady = function (callback, context = this) {
  if (window.plus) {
    callback.call(context)
  } else {
    document.addEventListener('plusready', callback.bind(context))
  }
}
Vue.mixin({
  beforeCreate () {
    onPlusReady(() => {
      this.plusReady = true
    }, this)
  },
  methods: {
    onPlusReady: onPlusReady
  }
})

import scroll from 'vue-seamless-scroll'

// 列表滚动组件
Vue.use(scroll)

// 创建bus
const bus = new Vue()
Vue.prototype.bus = bus

// 全局方法挂载
Vue.prototype.encrypt = encrypt
Vue.prototype.decrypt = decrypt
Vue.prototype.hideIdCardMiddle = hideIdCardMiddle
Vue.prototype.getDicts = getDicts
Vue.prototype.getDictMultiLevels = getDictMultiLevels
Vue.prototype.getDictsAnon = getDictsAnon
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabelMultiArray = selectDictLabelMultiArray
Vue.prototype.handlePicturePath = handlePicturePath
Vue.prototype.handleFileList = handleFileList
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.selectDeptName = selectDeptName
Vue.prototype.selectDeptNameByTree = selectDeptNameByTree
Vue.prototype.formatterType = formatterType
Vue.prototype.encryptEmail = encryptEmail
Vue.prototype.encryptIdCard = encryptIdCard
Vue.prototype.encryptPhone = encryptPhone
Vue.prototype.encryptName = encryptName
Vue.prototype.getRatio = getRatio
Vue.prototype.msgSuccess = function (msg) {
  this.$message({ showClose: true, message: msg, type: "success" });
}

Vue.prototype.msgError = function (msg) {
  this.$message({ showClose: true, message: msg, type: "error" });
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(msg);
}

// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.use(plugins)
Vue.use(permission)
Vue.use(Print);
DictData.install()
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get('size') || 'small' // set element-ui default size
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  //全局事件总线 $bus 组件间传参
  beforeCreate() {
    Vue.prototype.$bus = this;
  },
  render: h => h(App)
})

Vue.prototype.fontSize =function(res){
  let docEl = document.documentElement,
    clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
  if (!clientWidth) return;
  let fontSize = 100 * (clientWidth / 1920);
  return res*fontSize;
}
